#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n = 0;
	scanf("%d",&n);
	int* arr = (int*)malloc(sizeof(int) * n);
	if (NULL == arr)
	{
		perror("malloc fail");
		exit(-1);
	}
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&arr[i]);
	}

	int count = 1;
	int i = 1;
	while (i < n - 1)
	{
		if (arr[i - 1] < arr[i] && arr[i] > arr[i + 1])
		{
			++count;
		}

		if (arr[i - 1] > arr[i] && arr[i] < arr[i + 1])
		{
			++count;
		}
		++i;
	}

	printf("%d\n",count);
	return 0;
}

